﻿using System;

using Moe.ECamel.Common.Entities;
using Moe.ECamel.Client.Controllers;
using Moe.ECamel.Client.WinForms.Common;

namespace Moe.ECamel.Client.WinForms.Forms
{
	public partial class RentalDetailsForm : ECamelForm
	{
		private readonly EntityDetailsController<Rental> _controller;

		public RentalDetailsForm()
		{
			InitializeComponent();
		}
		public RentalDetailsForm(EntityDetailsController<Rental> controller)
			: this()
		{
			this._controller = controller;

			switch (_controller.Mode)
			{
//				case DetailsMode.Create:
//					this.Text = "הוספת השכרה חדשה";
//					break;
//				case DetailsMode.Edit:
//					this.Text = "עריכת פרטי השכרה";
//					break;
//				case DetailsMode.View:
				default:
					this.Text = "פרטי השכרה";
					break;
			}

			ApplyPermissions();
			Bind();
		}

		private void ApplyPermissions()
		{
			this.RentalDetailsControl.DetailsMode = _controller.Mode;
		}
		private void Bind()
		{
			this.RentalDetailsControl.Bind(_controller.Entity);
		}

		private void CancellationButton_Click(object sender, EventArgs e)
		{
			this.RentalDetailsControl.CancelEdit();
			this.Close();
		}
	}
}
